#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include "experiment_2_3_3.h"

List FindCommon(List, List);

int main()
{
    List L1, L2, common;
    L1 = Initialize();
    L2 = Initialize();

    Insert_Many(L1);
    Insert_Many(L2);
    common = FindCommon(L1, L2);
    Traverse(common);

    return 0;
}

List FindCommon(List L1, List L2)
{
    Position p = L1->next;
    List common = Initialize();
    int x, common_count = 0;
    while (p != NULL)
    {
        x = p->value;
        if (FindValue(L2, x) > 0)
            Insert(common, x, ++common_count);
        p = p->next;
    }

    return common;
}